<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>创建新文章 - 个人博客</title>
    <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#3B82F6',
                        secondary: '#10B981',
                        danger: '#EF4444',
                        dark: '#1F2937',
                        light: '#F9FAFB'
                    },
                    fontFamily: {
                        sans: ['Inter', 'system-ui', 'sans-serif'],
                    },
                }
            }
        }
    </script>
    <style type="text/tailwindcss">
        @layer utilities {
            .content-auto {
                content-visibility: auto;
            }
            .btn {
                @apply px-4 py-2 rounded-md font-medium transition-all duration-200 transform hover:scale-105 focus:outline-none focus:ring-2 focus:ring-opacity-50;
            }
            .btn-primary {
                @apply bg-primary text-white hover:bg-primary/90 focus:ring-primary;
            }
            .btn-danger {
                @apply bg-danger text-white hover:bg-danger/90 focus:ring-danger;
            }
            .btn-secondary {
                @apply bg-secondary text-white hover:bg-secondary/90 focus:ring-secondary;
            }
        }
    </style>
</head>
<body class="bg-gray-50 min-h-screen font-sans flex flex-col">
    <header class="bg-white shadow-md">
        <div class="container mx-auto px-4 py-4 flex justify-between items-center">
            <h1 class="text-2xl font-bold text-blue-600">个人博客</h1>
            <div>
                {% if current_user.is_authenticated %}
                <div class="flex items-center space-x-4">
                    <span class="text-gray-700">欢迎，{{ current_user.email }}</span>
                    <a href="{{ url_for('logout') }}" class="bg-red-500 hover:bg-red-700 text-white font-bold py-1 px-3 rounded text-sm">
                        登出
                    </a>
                </div>
                {% else %}
                <div class="space-x-2">
                    <a href="{{ url_for('login') }}" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-1 px-3 rounded text-sm">
                        登录
                    </a>
                    <a href="{{ url_for('register') }}" class="bg-green-500 hover:bg-green-700 text-white font-bold py-1 px-3 rounded text-sm">
                        注册
                    </a>
                </div>
                {% endif %}
            </div>
        </div>
    </header>
    <div class="container mx-auto px-4 py-8 max-w-4xl flex-grow">
        <header class="mb-8">
            <div class="mb-6">
                <a href="{{ url_for('index') }}" class="text-primary hover:underline inline-flex items-center">
                    <i class="fa fa-arrow-left mr-2"></i>返回首页
                </a>
            </div>
            <h1 class="text-3xl font-bold text-dark mb-2">创建新文章</h1>
            <p class="text-gray-600">撰写并发布您的新博客文章</p>
        </header>

        <div class="bg-white rounded-lg shadow-md p-6 mb-8">
            <form action="{{ url_for('new_post') }}" method="POST">
                <div class="mb-6">
                    <label for="title" class="block text-gray-700 font-medium mb-2">文章标题</label>
                    <input 
                        type="text" 
                        id="title" 
                        name="title" 
                        placeholder="请输入文章标题" 
                        class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary transition-all"
                        required
                    >
                </div>
                <div class="mb-6">
                    <label for="content" class="block text-gray-700 font-medium mb-2">文章内容</label>
                    <textarea 
                        id="content" 
                        name="content" 
                        rows="12" 
                        placeholder="请输入文章内容..." 
                        class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary transition-all font-mono"
                        required
                    ></textarea>
                    <p class="text-sm text-gray-500 mt-2">支持基本的Markdown语法</p>
                </div>
                <div class="flex justify-between">
                    <a href="{{ url_for('index') }}" class="btn bg-gray-200 text-gray-700 hover:bg-gray-300 focus:ring-gray-400">
                        取消
                    </a>
                    <button type="submit" class="btn btn-primary">
                        <i class="fa fa-paper-plane mr-2"></i>发布文章
                    </button>
                </div>
            </form>
        </div>
    </div>

    <footer class="bg-dark text-white py-8 mt-16">
        <div class="container mx-auto px-4 max-w-4xl text-center">
            <p>© {{ now.year }} 个人博客系统</p>
        </div>
    </footer>

    {% with messages = get_flashed_messages(with_categories=true) %}
        {% if messages %}
        <div class="fixed bottom-4 right-4 z-50">
            {% for category, message in messages %}
            <div class="{{ 'bg-green-500' if category == 'success' else 'bg-red-500' }} text-white px-6 py-4 rounded-lg shadow-lg mb-3 flex items-center">
                <i class="fa {{ 'fa-check-circle' if category == 'success' else 'fa-exclamation-circle' }} mr-3"></i>
                <span>{{ message }}</span>
                <button class="ml-auto text-white hover:text-gray-200" onclick="this.parentElement.remove()">
                    <i class="fa fa-times"></i>
                </button>
            </div>
            {% endfor %}
        </div>
        {% endif %}
    {% endwith %}

    <script>
        // 添加当前年份到页脚
        document.addEventListener('DOMContentLoaded', function() {
            const footerYear = document.querySelector('footer p');
            if (footerYear) {
                footerYear.innerHTML = footerYear.innerHTML.replace('{{ now.year }}', new Date().getFullYear());
            }
        });
    </script>
</body>
</html>